package likou;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/07/15 14:48
 */
public class _114 {
    public static void main(String[] args) {
        TreeNode tree = TreeUtil.createTree(new Integer[]{3,1,4,null,2});
        flatten(tree);
        System.out.println(123);
    }

    public static void flatten(TreeNode root) {
        if (root == null) return;
        flatten(root.left);
        flatten(root.right);
        TreeNode left = root.left;
        TreeNode right = root.right;
        root.left = null;
        root.right = left;
        TreeNode p = root;
        while (p.right != null) {
            p = p.right;
        }
        p.right = right;
    }
}
